import "../../../../scss/activity/group_buy/group_list.scss"
import $ from "jquery"
import Vue from "vue"
import com from "../../../utils/common"

$(function () {

  let page = {
    _actid: com.getUrlParam("actid") ? com.getUrlParam("actid") : 1,
    _app: {},

    _appData: {
      JoinerRank: [
      ],
    },
    _init:function () {

      let self = this;
      com.ajax({
        url:"/act/groupby/getGroups",
        data:{
          Actid : self._actid,
        },
        ok:function (data) {
          if(data["msg"] == "ok"){
            self._appData.JoinerRank = data["groups"];

            let BeforePrice = JSON.parse(data["act"].Prizes).BeforePrice;
            let joiners = 0;
            for(let i = 0;i < data["groups"].length;++i){
              joiners += data["groups"][i].Number;
            }
            self._appData.Joiners = joiners;
            self._appData.AllMoney = joiners * BeforePrice;
            self._loadTemp();
          }else{
            com.alertDialog('活动数据错误');
          }
        }
      })

    },
    _loadTemp:function () {
      let self = this;
      self._app = new Vue({
        el: "#app",
        data: self._appData,
        methods: {
          GroupDetail:function(joinid){
            window.location = "/dist/activity/group_buy/group_detail_list.html?actid=" + self._actid + "&joinid=" + joinid;
          },
          Withdraw:function(){
            com.alertDialog("请与客服代表联系")
          }
        },
      })
    }
  }

  page._init()

})



